package top.zhangjianyong.blog.enums;

import lombok.Getter;

/**
 * STS 操作类型枚举
 *
 * @author zhangjianyong
 * @since 2024-01-01
 */
@Getter
public enum StsOperationType {

    UPLOAD("upload", "oss:PutObject"),
    DOWNLOAD("download", "oss:GetObject"),
    DELETE("delete", "oss:DeleteObject"),
    UPLOAD_DOWNLOAD("upload_download", "oss:PutObject", "oss:GetObject");

    private final String code;
    private final String[] actions;

    StsOperationType(String code, String... actions) {
        this.code = code;
        this.actions = actions;
    }

    public static StsOperationType fromCode(String code) {
        for (StsOperationType type : values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        return UPLOAD_DOWNLOAD; // 默认返回上传下载权限
    }
} 